SubscriptionRefType
SubscriptionRef
SubscriptionRef<'a> is a reference whose changes can be streamed. changes
starts with the value current when the stream starts, then delivers every later update, with no gap and no duplicate
between the two, buffered by a QueueStrategy chosen per stream.
Use it for state that consumers join at different times, such as a display opened after a feed started. Update it with
set, update, or
modify; with a lossless buffer each update reaches every running stream before
the next starts. That no-miss guarantee holds for QueueStrategy.Unbounded and for a QueueStrategy.BackPressure
buffer that never fills; a full Dropping or Sliding buffer discards the newest value or evicts the oldest instead,
so a busy stream can miss updates. See the Queue guide for what each strategy does
when it is full.
Read the SubscriptionRef guide.
Specification
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Operations | ||
| make | SubscriptionRef.make value | Creates a reference holding value. |
| get | SubscriptionRef.get reference | Reads the current value. |
| set | SubscriptionRef.set value reference | Replaces the value and delivers it to every changes stream. |
| update | SubscriptionRef.update mapping reference | Applies a pure function to the value and delivers the result to every changes stream. |
| modify | SubscriptionRef.modify mapping reference | Computes a result and a new value together, stores the new value, and returns the result. |
| changes | SubscriptionRef.changes strategy reference | Streams the current value followed by every later update, buffered for this stream by strategy. |
Operations
strategy.
Parameters
| Name | Type | Description |
|---|---|---|
| strategy | QueueStrategy | |
| reference | SubscriptionRef<'a> |
Returns
Verification Examples
temperature
|> SubscriptionRef.changes (QueueStrategy.Sliding 1)
|> FlowStream.runForEach (printfn "%.1f")
